
** As several datasets used in the analysis are proprietary and cannot be shared, 
** this code is only given to help reserachers to understand the set up of our 
** databases and main variables.

********************************************************************************
* This file launches all the scripts sequentially to reproduce the analysis
* contained in the paper Activity Shocks and Corporate Liquidity:
* the Role of Trade Credit.
*
* Script: do/Main.do

* Authors:	
*			Anne Duquerroy  [anne.duquerroy@banque-france.fr]
*			Benjamin Bureau [benjamin.bureau@banque-france.fr]
*			Frédéric Vinas  [frederic.vinas@banque-france.fr]
* Date: 	Jan. 19, 2024
********************************************************************************

********************************************************************************
*
* IMPORTANT: 
* For confidentiality reason, the databases used in the paper cannot be provided 
* as Payment Defaults and Non performing loans data cannot be shared. 
*
* A pseudo-dataset is provided for Regression analysis, Figures and Descriptive 
* Statistics tables. 
* This dataset is only provided to illustrate the format of the original data. 
* Values are random, so the pseudo-dataset does NOT reproduce the results 
* reported in the paper.
*
********************************************************************************

* Prior to running the stata scripts, one should run the SAS program 
* Altman_score_SAS_code, that calculates the Z-scores of the firms.


* system and package specifications for replication (stata 15 was used)
log using "../log/sys_pkg.log", replace name(sys_pkg)

display c(version) 		// stata version
display c(edition_real) // stata edition
display c(machine_type) // machine_type

global lpackages carryforward distinct eclplot estadd estout ftools parmby ///
	quantiles reghdfe sencode winsor gsort

foreach pkg of global lpackages {
	which `pkg'
}

log close sys_pkg

** -- 0. Manually install the parmby package that does not work with old stata versions
/*
do ../do/parmest/metaparm.do
do ../do/parmest/parmby.do
do ../do/parmest/parmcip.do
do ../do/parmest/parmest.do
do ../do/parmest/sencode.do
*/

** -- I. Cleaning of the raw datasets and merging them 

do ../do/Make_base.do

** -- II. Make Panel for regressions 

do ../do/Prepare_data_for_regressions.do

** -- III. Make panel for bankruptcy regressions on longer time period

do ../do/Prepare_data_for_bankruptcy_regressions.do

** -- IV. Regression analysis + Figures + Descriptive statistics

do ../do/Replication_code.do

exit
